package com.zhihesj.anan.filter;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * @author anan.
 * @version 1.0
 * @create 2020-07-30 14-13
 */
@Configuration
public class FilterConfig {

    /**
     * 注册过滤器
     *
     * @return FilterRegistrationBean
     */
    @Bean
    public FilterRegistrationBean someFilterRegistration() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(replaceStreamFilter());
        registration.addUrlPatterns("/*");
        registration.setName("streamFilter");
        return registration;
    }

    /**
     * 实例化StreamFilter
     * @return Filter
     */
    @Bean(name = "replaceStreamFilter")
    public ReplaceStreamFilter replaceStreamFilter() {
        return  new ReplaceStreamFilter();
    }
}
